package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.mine.entity.MineOrderDataBean;
import com.beiing.tianshuai.tianshuai.mine.entity.OrderDeleteBean;
import com.beiing.tianshuai.tianshuai.mine.entity.OrderExtendTransportBean;
import com.beiing.tianshuai.tianshuai.mine.model.OrderDataModel;
import com.beiing.tianshuai.tianshuai.mine.model.OrderDataModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.OrderDataViewImpl;

/**
 * Created by ZH on 2018/3/27.
 * 订单详情页 Presenter
 */

public class OrderDataPresenter implements OrderDataPersenterlmpl,
        OrderDataModel.OnOrderDataResponseListener,
        OrderDataModel.OnOrderExtentListener,
        OrderDataModel.OnOrderDeleteListener {
    private OrderDataViewImpl mView;
    private OrderDataModelImpl mModel;

    public OrderDataPresenter(OrderDataViewImpl view) {
        mView = view;
        mModel = new OrderDataModel(this,this,this);
    }

    @Override
    public void getOrderStatus(String oid) {
        mView.showProgress();
        mModel.getOrderDetail(oid);
    }

    //开始延长收货请求
    @Override
    public void getOrderExtentTransport(String oid) {
        //mView.showProgress();
        mModel.getOrderExtentTransport(oid);
    }

    @Override
    public void getOrderDelete(String oid) {
        //mView.showProgress();
        mModel.getOrderDelete(oid);
    }

    @Override
    public void onGetDetailSuccess(MineOrderDataBean bean) {
        //请求成功返回
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onGetDetailError(Throwable throwable) {

    }

    @Override
    public void onExtentSuccess(OrderExtendTransportBean bean) {
        //mView.hideProgress();
        mView.extentOrderSuccess(bean);//
    }

    @Override
    public void onExtentError(Throwable throwable) {
       // mView.showProgress();//显示加载界面
        mView.extentOrderError(throwable);
    }

    @Override
    public void onGetDeleteSuccess(OrderDeleteBean bean) {
        //mView.hideProgress();
        mView.delOrderSuccess(bean);//
    }

    @Override
    public void onGetDeleteError(Throwable throwable) {
        //mView.showProgress();//显示加载界面
        mView.delOrderError(throwable);
    }
}
